//
//  CVBleObj.h
//  外设端
//
//  Created by apple on 16/4/6.
//  Copyright © 2016年 SherrySorftware. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

/**<  外设状态*/
typedef NS_ENUM(NSInteger,PMSTATE) {
    StatePoweredOn = 0,
    StatePoweredOff,
    StateUnknown ,
    StateResetting,
    Unsupported,
    StateUnauthorized,
};

typedef NS_ENUM(NSInteger,CVSearchcharacteristic) {
    CVCharacteristic1 = 0,
    CVCharacteristic2 ,
    CVCharacteristicTemp,
};

@protocol bleObjDelegate <NSObject>

@optional
- (void)peripheralManagerDidUpdateState:(PMSTATE)state;
@optional
- (void)logDidUpdata:(NSString*)string;
@end

static NSString *const ServiceUUID1                = @"FFF0";
static NSString *const notiyCharacteristicUUID     = @"FFF1";
static NSString *const notiyCharacteristicUUIDb    = @"FFFB";
static NSString *const readwriteCharacteristicUUID = @"FFF2";
static NSString *const ServiceUUID2                = @"FFE0";
static NSString *const readCharacteristicUUID      = @"FFE1";
static NSString * const LocalNameKey               = @"myPeripheral";

@interface CVBleObj : NSObject<CBPeripheralManagerDelegate>
{
    //添加成功的service数量
    int serviceNum;
    CBMutableCharacteristic *readwriteCharacteristic;/**< 可读写 */
    CBMutableCharacteristic *notiyCharacteristic;/**< 可通知 */
    CBMutableCharacteristic *notiyCharacteristicb;/**< 可通知 */
    CBCharacteristic *characteristicTemp;
    CBCharacteristic *characteristicTempb;
    NSTimer *timer;
}
@property(strong,nonatomic) CBCentralManager *manager;/**< 系统蓝牙设备管理对象，可以把他理解为主设备，通过他，可以去扫描和链接外设*/
@property(strong,nonatomic) CBPeripheralManager *peripheralManager;
+(CVBleObj*)shareDelegate;/*!
 *	@author  jiaminqi_u@126.com
 *
 *	@brief 给某个characteristic写入值
 *
 *	@param string					写入的值
 *
 *	@return 返回成功或者失败
 */
- (BOOL)sendDataWithString:(NSString*)string characteristic:(CVSearchcharacteristic)num;
-(BOOL)sendData:(NSTimer *)t;
@property (assign, nonatomic) id<bleObjDelegate>delegate;
@property (retain, nonatomic) NSString *log;


@end
